#include "qresourcefolderwidget.h"

#include "qaddresourcedialog.h"

#include "../../libs/coreLib/styledbar.h"
#include "../../libs/coreLib/qactiontoolbar.h"
#include "../../libs/coreLib/qresourcetreewidget.h"
#include "../../libs/coreLib/qsoftcore.h"

#include <QVBoxLayout>
#include <QIcon>
#include <QLabel>

QResourceFolderWidget::QResourceFolderWidget(QWidget *parent) :
    QWidget(parent),
    m_floderList(new CORELIB::QResourceTreeWidget),
    m_styledBar(new CORELIB::StyledBar)

{
    QVBoxLayout *v=new QVBoxLayout;
    v->setSpacing(0);
    v->setMargin(0);
    v->addWidget(m_styledBar);
    v->addWidget(m_floderList);
    this->setLayout(v);

    CORELIB::QActionToolBar *toolbar=new CORELIB::QActionToolBar(Qt::AlignRight);

    CORELIB::QSoftCore *core=CORELIB::QSoftCore::getCore();

    QList<QAction*> list;
    QAction *ac;

    ac=new QAction(this);
    ac->setSeparator(true);
    list.append(ac);

    ac=core->action("ResourceManager-Add");
    if(ac!=NULL)
    {
        list.append(ac);
        connect(ac,SIGNAL(triggered()),this,SLOT(add()));
    }

    ac=core->action("ResourceManager-Del");
    if(ac!=NULL)
    {
        list.append(ac);
        connect(ac,SIGNAL(triggered()),this,SLOT(remove()));
    }
    toolbar->addButtonActions(list);


    v=new QVBoxLayout;
    v->setMargin(0);
    v->setSpacing(0);
    v->addWidget(toolbar);
    m_styledBar->setLayout(v);

    QLabel *label=new QLabel(tr("Resource List"));
    label->setStyleSheet("color:rgb(255,255,255);");
    toolbar->setLabelWidget(label);

    connect(m_floderList,SIGNAL(selectChanged(QString,QString)),this,SIGNAL(select(QString,QString)));
}

void QResourceFolderWidget::add()
{
    QAddResourceDialog dlg(this);
    dlg.exec();
}

void QResourceFolderWidget::remove()
{

}
